#!/usr/bin/env python
# -*- coding: UTF-8 -*-

'''
Copyright (C) 2009 dbzhang800@gmail.com
All rights reserved.
''' 
import win32gui
import win32com
import win32com.client
import pythoncom
import time

class Test:
    def runtest(self):
        print 'test'

class EventHandler:
    def OnVisible(self,visible):
        global bVisibleEventFired
        bVisibleEventFired = 1
    def OnDownloadBegin(self):
        print 'DownloadBegin'
        self.runtest()
        self.value = 1
    def OnDownloadComplete(self):
        print 'DownloadComplete'
        self.value += 1
    def OnDocumentComplete(self,pDisp=pythoncom.Missing,URL=pythoncom.Missing):
        print 'documentComplete of %s' %URL
        print self.value

class H(Test,EventHandler):
    pass

ie = win32com.client.DispatchWithEvents('InternetExplorer.Application',H)
ie.Visible = 1
ie.Navigate("www.sohu.com")
pythoncom.PumpMessages()
ie.Quit()
